﻿using System;

namespace PoolKit.Strategies.Creation
{
    internal static class ResourceCreationStrategyExtensions
    {
        public static ResourceCreationStrategy<TResource> ToThreadSafe<TResource>(this ResourceCreationStrategy<TResource> strategy)
        {
            if (strategy == null) throw new ArgumentNullException("strategy");

            if (strategy.ThreadingContract == ThreadingContract.Multithreaded)
            {
                return strategy;
            }

            return new ResourceCreationStrategyThreadSafe<TResource>(strategy);
        }
    }
}